#pragma once
#include <stddef.h>

namespace as
{
	struct Handle {
		int bits;
		int freelist;
		unsigned int h[1];
	};

	size_t handle_size(int bits);
	void handle_init(struct Handle *H, struct Handle *old, int bits, size_t sz);
	unsigned int handle_new(struct Handle *H);
	int handle_import(struct Handle *H, unsigned int id, int invalid);	// 0 succ
	unsigned int handle_index(struct Handle *H, int index);
	int handle_invalid(struct Handle *H, unsigned int id);
	void handle_remove(struct Handle *H, unsigned int id);
	unsigned int handle_each(struct Handle *H, unsigned int last);
	unsigned int handle_each_available(struct Handle *H, unsigned int last);
}
